<?php echo $header; ?><?php echo $column_left; ?>
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-category" data-toggle="tooltip" title="<?php echo $button_save; ?>" class="btn btn-primary"><i class="fa fa-save"></i></button>
        <a href="<?php echo $cancel; ?>" data-toggle="tooltip" title="<?php echo $button_cancel; ?>" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
      <h1><?php echo $heading_title; ?></h1>
      <ul class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
        <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
        <?php } ?>
      </ul>
    </div>
  </div>
  <div class="container-fluid">
    <?php if ($error_warning) { ?>
    <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    <?php } ?>
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-pencil"></i> <?php echo $text_form; ?></h3>
      </div>
      <div class="panel-body">
        <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-category" class="form-horizontal">
          <!-- <input type="hidden" name="project_customer_id" value="<?php echo $project_customer_id; ?>" >  -->
          <ul class="nav nav-tabs">
            <li class="active"><a href="#tab-general" data-toggle="tab"><?php echo $tab_general; ?></a></li>
          </ul>
          <div class="tab-content">
            <div class="tab-pane active" id="tab-general">
              <ul class="nav nav-tabs" id="language">
                <?php foreach ($languages as $language) { ?>
                <li><a href="#language<?php echo $language['language_id']; ?>" data-toggle="tab"><img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /> <?php echo $language['name']; ?></a></li>
                <?php } ?>
              </ul>
              <div class="tab-content">
                <?php foreach ($languages as $language) { ?>
                <div class="tab-pane" id="language<?php echo $language['language_id']; ?>">

<!--                   <div class="form-group required">
                    <label class="col-sm-2 control-label" for="input-status"><?php echo $entry_status; ?></label>
                    <div class="col-sm-8">
                      <input type="text" name="status" value="<?php echo $status; ?>" placeholder="<?php echo $entry_status; ?>" id="input-status" class="form-control" />
                    </div>
                  </div> -->

                  <div class="form-group required">
                    <label class="col-sm-2 control-label" for="input-title_cn"><?php echo $entry_title_cn; ?></label>
                    <div class="col-sm-8">
                      <input type="text" name="title_cn" value="<?php echo $title_cn; ?>" placeholder="<?php echo $entry_title_cn; ?>" id="input-title_cn" class="form-control" />
                    </div>
                  </div>
                  <div class="form-group required">
                    <label class="col-sm-2 control-label" for="input-title_en"><?php echo $entry_title_en; ?></label>
                    <div class="col-sm-8">
                      <input type="text" name="title_en" value="<?php echo $title_en; ?>" placeholder="<?php echo $entry_title_en; ?>" id="input-title_en" class="form-control" />
                    </div>
                  </div>
                  <div class="form-group required">
                    <label class="col-sm-2 control-label" for="input-description_cn"><?php echo $entry_details_cn; ?></label>
                    <div class="col-sm-10">
                      <textarea name="details_cn" placeholder="<?php echo $entry_details_cn; ?>" id="input-description_cn" class="form-control"><?php echo  $details_cn; ?></textarea>
                      <?php if (isset($error_description[$language['language_id']])) { ?>
                      <div class="text-danger"><?php echo $error_description[$language['language_id']]; ?></div>
                      <?php } ?>
                    </div>
                  </div>
                  <div class="form-group required">
                    <label class="col-sm-2 control-label" for="input-description_en"><?php echo $entry_details_en; ?></label>
                    <div class="col-sm-10">
                      <textarea name="details_en" placeholder="<?php echo $entry_details_en; ?>" id="input-description_en" class="form-control"><?php echo $details_en; ?></textarea>
                      <?php if (isset($error_description[$language['language_id']])) { ?>
                      <div class="text-danger"><?php echo $error_description[$language['language_id']]; ?></div>
                      <?php } ?>
                    </div>
                  </div>      

                </div>
                <?php } ?>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
  <script type="text/javascript"><!--

$('#input-description_cn').summernote({
	height: 300
});
$('#input-description_en').summernote({
  height: 300
});
//--></script> 
<script type="text/javascript">

//股東
$('body').on('click', '.button-upload_ic',function() {
  var dn = $(this).attr('data-id');
  $('#form-upload').remove();
  var name = $(this).attr('id');
  $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');

  $('#form-upload input[name=\'file\']').trigger('click');

  if (typeof timer != 'undefined') {
      clearInterval(timer);
  }

  timer = setInterval(function() {
    if ($('#form-upload input[name=\'file\']').val() != '') {
      clearInterval(timer);

      // Reset everything
      $('.alert').remove();
      $('#progress-bar').css('width', '0%');
      $('#progress-bar').removeClass('progress-bar-danger progress-bar-success');
      $('#progress-text').html('');

      $.ajax({
        url: 'index.php?route=hk/company_setup/uploads&token=<?php echo $token; ?>',
        type: 'post',
        dataType: 'json',
        data: new FormData($('#form-upload')[0]),
        cache: false,
        contentType: false,
        processData: false,
        beforeSend: function() {
          $('button[data-type=\''+name+'_upload\']').button('loading');
        },
        complete: function() {
          $('.button-upload').button('reset');
        },
        success: function(json) {

          // $('input[name=\''+name+'_url\']').attr('value', json['project_file_id']);
          // $('button[data-clear=\''+name+'_clear\']').attr('data-name', json['project_file_id']);
          if (json['error']) {
            alert("文件上傳類型不符合");return false;
          }

          if(json['success']){
            alert('上傳成功');
            // console.log($(hf).length,json['fileurl']);
            $('#gd_id_card_'+dn).val(json['filename']);
            $('.gd_id_card_href_'+dn+'').attr('href',json['fileurl']).css('display','');
            $('#'+name).css('display','none');
          }
        },
        error: function(xhr, ajaxOptions, thrownError) {
          alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
      });
    }
  }, 500);
});
$('body').on('click', '.button-upload_ap',function() {
  var dn = $(this).attr('data-id');
  $('#form-upload').remove();
  var name = $(this).attr('id');
  $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');

  $('#form-upload input[name=\'file\']').trigger('click');

  if (typeof timer != 'undefined') {
      clearInterval(timer);
  }

  timer = setInterval(function() {
    if ($('#form-upload input[name=\'file\']').val() != '') {
      clearInterval(timer);

      // Reset everything
      $('.alert').remove();
      $('#progress-bar').css('width', '0%');
      $('#progress-bar').removeClass('progress-bar-danger progress-bar-success');
      $('#progress-text').html('');

      $.ajax({
        url: 'index.php?route=hk/company_setup/uploads&token=<?php echo $token; ?>',
        type: 'post',
        dataType: 'json',
        data: new FormData($('#form-upload')[0]),
        cache: false,
        contentType: false,
        processData: false,
        beforeSend: function() {
          $('button[data-type=\''+name+'_upload\']').button('loading');
        },
        complete: function() {
          $('.button-upload').button('reset');
        },
        success: function(json) {

          // $('input[name=\''+name+'_url\']').attr('value', json['project_file_id']);
          // $('button[data-clear=\''+name+'_clear\']').attr('data-name', json['project_file_id']);
          if (json['error']) {
            alert("文件上傳類型不符合");return false;
          }

          if(json['success']){
            alert('上傳成功');
            // console.log($(hf).length,json['fileurl']);
            $('#gd_address_proof_'+dn).val(json['filename']);
            $('.gd_address_proof_href_'+dn+'').attr('href',json['fileurl']).css('display','');
            $('#'+name).css('display','none');
          }
        },
        error: function(xhr, ajaxOptions, thrownError) {
          alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
      });
    }
  }, 500);
});






//董事
$('body').on('click', '.button-upload2_ic',function() {
  var dn = $(this).attr('data-id');
  $('#form-upload').remove();
  var name = $(this).attr('id');
  console.log(dn,name);
  $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');

  $('#form-upload input[name=\'file\']').trigger('click');

  if (typeof timer != 'undefined') {
      clearInterval(timer);
  }

  timer = setInterval(function() {
    if ($('#form-upload input[name=\'file\']').val() != '') {
      clearInterval(timer);

      // Reset everything
      $('.alert').remove();
      $('#progress-bar').css('width', '0%');
      $('#progress-bar').removeClass('progress-bar-danger progress-bar-success');
      $('#progress-text').html('');

      $.ajax({
        url: 'index.php?route=hk/company_setup/uploads&token=<?php echo $token; ?>',
        type: 'post',
        dataType: 'json',
        data: new FormData($('#form-upload')[0]),
        cache: false,
        contentType: false,
        processData: false,
        beforeSend: function() {
          $('button[data-type=\''+name+'_upload\']').button('loading');
        },
        complete: function() {
          $('.button-upload').button('reset');
        },
        success: function(json) {

          // $('input[name=\''+name+'_url\']').attr('value', json['project_file_id']);
          // $('button[data-clear=\''+name+'_clear\']').attr('data-name', json['project_file_id']);
          if (json['error']) {
            alert("文件上傳類型不符合");return false;
          }

          if(json['success']){
            alert('上傳成功');
            // console.log($(hf).length,json['fileurl']);
            $('#ds_id_card_'+dn).val(json['filename']);
            $('.ds_id_card_href_'+dn+'').attr('href',json['fileurl']).css('display','');
            $('#'+name).css('display','none');
          }
        },
        error: function(xhr, ajaxOptions, thrownError) {
          alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
      });
    }
  }, 500);
});
$('body').on('click', '.button-upload2_ap',function() {
  var dn = $(this).attr('data-id');
  $('#form-upload').remove();
  var name = $(this).attr('id');
  $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');

  $('#form-upload input[name=\'file\']').trigger('click');

  if (typeof timer != 'undefined') {
      clearInterval(timer);
  }

  timer = setInterval(function() {
    if ($('#form-upload input[name=\'file\']').val() != '') {
      clearInterval(timer);

      // Reset everything
      $('.alert').remove();
      $('#progress-bar').css('width', '0%');
      $('#progress-bar').removeClass('progress-bar-danger progress-bar-success');
      $('#progress-text').html('');

      $.ajax({
        url: 'index.php?route=hk/company_setup/uploads&token=<?php echo $token; ?>',
        type: 'post',
        dataType: 'json',
        data: new FormData($('#form-upload')[0]),
        cache: false,
        contentType: false,
        processData: false,
        beforeSend: function() {
          $('button[data-type=\''+name+'_upload\']').button('loading');
        },
        complete: function() {
          $('.button-upload').button('reset');
        },
        success: function(json) {

          // $('input[name=\''+name+'_url\']').attr('value', json['project_file_id']);
          // $('button[data-clear=\''+name+'_clear\']').attr('data-name', json['project_file_id']);
          if (json['error']) {
            alert("文件上傳類型不符合");return false;
          }

          if(json['success']){
            alert('上傳成功');
            // console.log($(hf).length,json['fileurl']);
            $('#ds_address_proof_'+dn).val(json['filename']);
            $('.ds_address_proof_href_'+dn+'').attr('href',json['fileurl']).css('display','');
            $('#'+name).css('display','none');
          }
        },
        error: function(xhr, ajaxOptions, thrownError) {
          alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
      });
    }
  }, 500);
});






















$('body').on('click','.button-clear', function() {
  // console.log(111);
  var data_type = $(this).attr('data-type');
  // var da = {
  //     name:$(this).attr('data-name'),
  //     id:$(this).attr('data-id'),
  //     project_customer_id:$("input[name=\'project_customer_id\']").val(),
  // };
  var id = $(this).attr('data-id');
  var r=confirm("Are you sure?");
  if( r == true ){
  $.ajax({
    url: 'index.php?route=project/project_customer/clear&token=<?php echo $token; ?>',
    data:da,
    dataType: 'json',
    beforeSend: function() {
      $('#button-clear').button('loading');
    },
    complete: function() {
      $('#button-clear').button('reset');
    },
    success: function(json) {
      $('.alert').remove();

      if (json['error']) {
        $('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
      }

      if (json['success']) {
        $('input[name=\''+id+'_name\']').attr('value', '');
        $('input[name=\''+id+'_url\']').attr('value','');
          $('button[data-clear=\''+id+'_clear\']').attr('data-name', '');
          $('.'+data_type+'').remove();
          alert('Clear Success'); return false;
      }
    },
    error: function(xhr, ajaxOptions, thrownError) {
      alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
    }
  });
}
});
</script>




  <script type="text/javascript"><!--
$('#language a:first').tab('show');
//--></script></div>
<?php echo $footer; ?>